<?php
	require 'db.php';
	$name=$_POST['name'];
	$email=$_POST['email'];
	$mobile=$_POST['mobile'];
	$gender=@$_POST['gender'];
	if($name !== ""  && $email !== ""){
	
	mysql_query("INSERT INTO records(name, email, mobile, gender)VALUES('$name', '$email', '$mobile', '$gender')");
	
	$q="SELECT id FROM records ORDER BY id DESC LIMIT 1";
	$fid=(mysql_query($q));
	$rid=mysql_fetch_array($fid);
	$id=$rid['id'];

?>
<html>
	<link type="text/css" rel="stylesheet" href="css/style.css" />
	<body>
		
<table width="100%">
	<tr>
		<th colspan="7">Record SuccessFully Inserted On #ID <?=$id ?> </th>
	</tr>
	<?php } else{?>
		<table width="100%">
	<tr>
		<th colspan="7">Record Not Inserted Some Field are blank  </th>
	</tr>
	<?php
	} ?>
	<tr>
		<td>#ID</td>
		<td>Name</td>
		<td>Email</td>
		<td>Mobile</td>
		<td>Gender</td>
		<td colspan="2" align="center">Action</td>
	</tr>
	<?php
	$fetch=mysql_query("SELECT * FROM records ORDER BY id DESC");
	while($data=mysql_fetch_assoc($fetch)){
		?>
		<tr class="update">
			<td><?=$data['id'] ?></td>
			<td><?=$data['name'] ?></td>
			<td><?=$data['email'] ?></td>
			<td><?=$data['mobile'] ?></td>
			<td><?=$data['gender'] ?></td>
			<td>
			<a href="#" id="<?=$data['id'] ?>" class="delete_button" onclick="return confirm('Are you sure you want to delete this file?');">X</a>
			</td>
			<td>
				<a href="#" id="edit.php?id=<?=$data['id'] ?>"  class="edit">
					Edit Record</a>
				
			</td>
		</tr>
<?php		
	}
	?>
</table>

<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/dl.js"></script>

</body>
</html>
